
import { ActionReducer } from '@ngrx/store';
import { AppState } from '../cne.state';

/**
 * 调试 Meta Reducer
 * 在开发环境下打印 action 和状态变化
 */
export function debug(
  reducer: ActionReducer<AppState>
): ActionReducer<AppState> {
  return (state, action) => {
    const newState = reducer(state, action);
    
    console.log(`[DEBUG] action: ${action.type}`, {
      payload: (action as any).payload,
      oldState: state,
      newState
    });
    
    return newState;
  };
}
